//
//  LDSLightCollectionViewCell.m
//  LDSSmartHome
//
//  Created by kai_leedarson on 2017/10/10.
//  Copyright © 2017年 leedarson. All rights reserved.
//

#import "LDSDDDCollectionCell.h"
#import "LDSDDDModel.h"

@implementation LDSDDDCollectionCell

- (void)viewSetup {
    _name = [UILabel new];
    _name.text = @"";
    _name.textColor = [UIColor lightGrayColor];
    _name.textAlignment = NSTextAlignmentCenter;
    _name.font = [UIFont systemFontOfSize:12.0f];
    _name.numberOfLines = 0;
    [_name sizeToFit];
    
    _photo = [[UIImageView alloc] init];
    _photo.contentMode = UIViewContentModeScaleAspectFit;
    _iconPhoto = [[UIImageView alloc] init];
    _iconPhoto.contentMode = UIViewContentModeScaleAspectFit;
    
    [self.contentView addSubview:_photo];
    [self.contentView addSubview:_iconPhoto];
    [self.contentView addSubview:_name];
    
}

- (void)frameSetup {
    _photo.frame = CGRectMake(0,0,self.bounds.size.width,self.bounds.size.height - 51);
    _name.frame = CGRectMake(5,self.bounds.size.height - 40,self.bounds.size.width - 10,40);
    _iconPhoto.frame = CGRectMake((self.bounds.size.width - 18)/2, self.bounds.size.height - 60, 18, 18);
}

- (void)setModel:(LDSDDDModel *)model {
    [super setModel:model];
    if (model) {
        self.name.text = model.name;
        self.photo.image = [UIImage imageNamed:model.imageName];
        self.iconPhoto.image = [UIImage imageNamed:@"devicemanage_icon_cloud_offline"];
    }
}
@end
